<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8"
	contentType="text/html;charset=UTF-8"%>
<%@ include file="/includes/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>用户管理</title>
<meta name="menu" content="user" />
<link rel="stylesheet" type="text/css"
	href="<c:url value='/styles/tablesorter/style.css'/>" />
<link rel="stylesheet" type="text/css"
	href="<c:url value='/styles/base.css'/>" />
<script type="text/javascript"
	src="<c:url value='/scripts/jquery.tablesorter.js'/>"></script>
</head>

<body>
	<form action="/user.do" id="listForm">
		<h1>用户列表</h1>
		<div align="right">
			<label>房间名:</label><input type="text" name="s"
				value="<c:out value="${s}" />" /> <input style="float: right"
				type="submit" value="搜索" />
		</div>
		<table id="tableList" class="tablesorter" cellspacing="1">
			<thead>
				<tr>
					<th align="center" width="5%">是否在线</th>
					<th align="center" width="10%">用户名</th>
					<th align="center" width="20%">上次登陆IP</th>
					<th align="center" width="20%">拥有角色</th>
					<th align="center" width="25%">注册时间</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach var="user" items="${page.content}">
					<tr>
						<td align="center"><c:choose>
								<c:when test="${user.online eq true}">
									<span title="在线"> <img src="images/user-online.png"
										alt="在线" />
									</span>
								</c:when>
								<c:otherwise>
									<span title="离线"> <img src="images/user-offline.png"
										alt="离线" />
									</span>
								</c:otherwise>
							</c:choose></td>
						<td><c:out value="${user.username}" /></td>
						<td><c:out value="${user.lastLoginIp}" /></td>
						<td>
							<table>
								<c:forEach var="role" items="${user.roles}">
									<tr>
										<td><c:out value="${role.nickname}" /></td>
										<td align="center"><c:choose>
												<c:when test="${role.isOnline eq true}">
													<span title="在线"> <img src="images/user-online.png"
														alt="在线" />
													</span>
												</c:when>
												<c:otherwise>
													<span title="离线"> <img src="images/user-offline.png"
														alt="离线" />
													</span>
												</c:otherwise>
											</c:choose></td>
									</tr>
								</c:forEach>
							</table>
						</td>
						<td align="center"><fmt:formatDate
								pattern="yyyy-MM-dd HH:mm:ss" value="${user.createDate}" /></td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
		<div>
			<c:import url="/includes/pagination.jsp"></c:import>
		</div>
	</form>

	<script type="text/javascript">
		//<![CDATA[
		$(function() {
			$('#tableList').tablesorter();
			//$('#tableList').tablesorter( {sortList: [[0,0], [1,0]]} );
			//$('table tr:nth-child(odd)').addClass('odd');
			$('table tr:nth-child(even)').addClass('even');
		});
		//]]>
	</script>

</body>
</html>
